﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Printing;
using System.Text;
using System.Windows.Forms;

namespace Demo
{
    public partial class Dialog : Form
    {
        public Dialog()
        {
            InitializeComponent();
        }

        private void colorDialogButton_Click(object sender, EventArgs e)
        {
            ColorDialog colorDialog = new ColorDialog();
         

            colorDialog.AllowFullOpen = false;
            colorDialog.AnyColor = false;
            colorDialog.ShowDialog();
        }

        private void fontDialogButton_Click(object sender, EventArgs e)
        {
            FontDialog fontDialog = new FontDialog();

            fontDialog.MinSize = 14;
            fontDialog.MaxSize = 28;
            fontDialog.ShowDialog();
        }

        private void openFileButton_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "Hi (*.doc)|*.txt|Hello (*.doc)|*.doc";
            openFileDialog.ShowDialog();
        }

        private void saveFileButton_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.OverwritePrompt = true;
            saveFileDialog.ShowDialog();
        }

        private void pageSetupButton_Click(object sender, EventArgs e)
        {
            PageSetupDialog pageSetupDialog = new PageSetupDialog();

            pageSetupDialog.Document = new PrintDocument();
            pageSetupDialog.ShowDialog();
        }

        private void printDialogButton_Click(object sender, EventArgs e)
        {
            PrintDialog printDialog = new PrintDialog();

            printDialog.ShowDialog();
        }

        private void printPreviewButton_Click(object sender, EventArgs e)
        {
            PrintPreviewDialog printPreviewDialog = new PrintPreviewDialog();

            printPreviewDialog.ShowDialog();
        }

        private void userDialogButton_Click(object sender, EventArgs e)
        {
            UserDialog userDialog = new UserDialog();

            if (userDialog.ShowDialog() == DialogResult.OK)
            {
                label1.Text = userDialog.Hoten + " - " + userDialog.NgaySinh.ToShortDateString();

            }
        }

        private void messageBoxButton_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Content", "Title", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.Cancel)
                label1.Text = "Cancel";
        }

    }
}
